<html>
<head><meta charset="utf-8"><title>cargo platform specific dependencies · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cargo.20platform.20specific.20dependencies.html">cargo platform specific dependencies</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211078546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cargo%20platform%20specific%20dependencies/near/211078546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Damon Smith <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cargo.20platform.20specific.20dependencies.html#211078546">(Sep 24 2020 at 00:41)</a>:</h4>
<p>Hi I have a problem trying to make a dependency work differently for different OSes. It should be simple but it doesn't work. I have a tetris game that uses SDL2. In macos it uses VCPKG to provide that dependency. In linux it just uses the sdl2 lib. I've used platform specific dependencies:</p>
<div class="codehilite"><pre><span></span><code>[target.&#39;cfg(target_os = &quot;linux&quot;)&#39;.dependencies.sdl2]
version = &quot;0.34.3&quot;
default-features = false
features = [&quot;ttf&quot;, &quot;mixer&quot;]

[target.&#39;cfg(target_os = &quot;macos&quot;)&#39;.dependencies.sdl2]
version = &quot;0.34.3&quot;
default-features = false
features = [&quot;ttf&quot;, &quot;mixer&quot;, &quot;static-link&quot;, &quot;use-vcpkg&quot;]
</code></pre></div>


<p>but in linux the build fails with "No vcpkg installation found. Set the VCPKG_ROOT environment variable or run \'vcpkg integrate install\'"</p>
<p>The linux build shouldn't be looking for VCPKG at all, that should be mac specific. If I remove the macos specific dependencies it builds and runs and plays fine in Linux. I wonder if this is a cargo issue or something weird they've done with the VCPKG crate.</p>



<a name="211078637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cargo%20platform%20specific%20dependencies/near/211078637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Damon Smith <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cargo.20platform.20specific.20dependencies.html#211078637">(Sep 24 2020 at 00:43)</a>:</h4>
<p>if anyone has any tips or clues that would be amazing and much appreciated!</p>



<a name="211078678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cargo%20platform%20specific%20dependencies/near/211078678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cargo.20platform.20specific.20dependencies.html#211078678">(Sep 24 2020 at 00:43)</a>:</h4>
<p>are you targeting linux or mac? the target is not necessarily the same as the host</p>



<a name="211080945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cargo%20platform%20specific%20dependencies/near/211080945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Damon Smith <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cargo.20platform.20specific.20dependencies.html#211080945">(Sep 24 2020 at 01:23)</a>:</h4>
<p>I'm not setting a target so it should be linux for me</p>



<a name="211081051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cargo%20platform%20specific%20dependencies/near/211081051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cargo.20platform.20specific.20dependencies.html#211081051">(Sep 24 2020 at 01:26)</a>:</h4>
<p>hmm, that's weird then</p>



<a name="211083241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cargo%20platform%20specific%20dependencies/near/211083241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cargo.20platform.20specific.20dependencies.html#211083241">(Sep 24 2020 at 02:10)</a>:</h4>
<p><span class="user-mention" data-user-id="345866">@Damon Smith</span> There is a nightly feature to enable this, see <a href="https://github.com/rust-lang/cargo/issues/7914">https://github.com/rust-lang/cargo/issues/7914</a>.</p>



<a name="211085604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cargo%20platform%20specific%20dependencies/near/211085604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Damon Smith <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cargo.20platform.20specific.20dependencies.html#211085604">(Sep 24 2020 at 03:02)</a>:</h4>
<p>amazing, thank you!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>